//请求前缀
var baseURL = "https://oxtoken.io";

//登录token
var token = localStorage.getItem("token");
if(token == null || token == ''){
    location.href = 'login.html';
}

//jquery全局配置
$.ajaxSetup({
	dataType: "json",
	cache: false,
    headers: {
        "Authorization": token
    },
    xhrFields: {
	    withCredentials: true
    },
    complete: function(xhr) {
        //token过期，则跳转到登录页面
        if(xhr.status == 500){
            location.href = 'login.html';
        } else if(xhr.status == 401){
            //删除本地token
            localStorage.removeItem("token");
            location.href = 'login.html';
        }
    }
});

